/**
 * Created by xxc on 2018/9/4.
 */
$(document).ready(function () {
    var arr = ["热门", "空调", "冰洗", "平板电视", "厨卫大电", "厨房小电", "生活电器", "个护健康", "店铺热销"];
    var ul = document.createElement("ul");
    for(var i=0;i<arr.length;i++){
        var em = document.createElement("em");
        var img = document.createElement("img");
        var li = document.createElement("li");
        li.appendChild(img);
        li.appendChild(em);
        ul.appendChild(li);
    }
    var div = document.createElement("div");
    div.className="tab-head";
    div.appendChild(ul);
    var jiadianBest = document.getElementById("jiadian-best");
    jiadianBest.appendChild(div);
    var em = jiadianBest.getElementsByTagName("em");
    var imgs = jiadianBest.getElementsByTagName("img");
    for(var i = 0;i<arr.length;i++){
        em[i].innerHTML = arr[i];
        imgs[i].src = "images/jiadian_best/dt/"+i+".webp";
    }
    var lis = jiadianBest.children[1].getElementsByTagName("li");
    jiadianBest.children[1].onmouseover = function () {
        for(var i = 0;i<lis.length;i++){
            lis[i].index = i;
            lis[i].onmouseover = function () {
                var n = this.index;
                this.children[0].src = "images/jiadian_best/dt/"+n+""+n+".webp";
            }
            lis[i].onmouseout = function () {
                var n = this.index;
                for(var i = 0;i<arr.length;i++){
                    imgs[i].src = "images/jiadian_best/dt/"+i+".webp";
                }
                jiadianBest.children[1].onmouseout= function () {
                    for(var i=0;i<arr.length;i++){
                        lis[i].children[0].src= "images/jiadian_best/dt/"+i+".webp";
                        lis[i].style.background = "#FFF";
                        lis[i].style.color = "#333";
                    }
                    lis[n].children[0].src= "images/jiadian_best/dt/"+n+""+n+".webp";
                    lis[n].style.background = "#F26E6E";
                    lis[n].style.color = "#fff";
                }
            }
        }
    }
});
